﻿using System;
using System.Collections.Generic;
using OOXMLGenerator.Enums;

namespace OOXMLGenerator.DataStructure
{
    /// <summary>
    /// Is a custom Section Content with PartContentType.ChangeRequests Type   
    /// </summary>
    public class CRSectionContent : SectionContent
    {
        /// <summary>
        /// Empty Constructor - initializes a new instance of the BOMSectionContent Class.
        /// Properties settings:
        /// Header = Properties.Resources.Header_ChangeRequests;
        /// Type = PartContentType.ChangeRequests
        /// Content = new instance of PartDataSet.PartChangeRequestsDataTable
        /// </summary>
        public CRSectionContent()
        {
            base.Header = Properties.Resources.Header_ChangeRequests;
            base.Type = PartContentType.ChangeRequests;
            base.Content = new PartDataSet.PartChangeRequestsDataTable();
        }

        /// <summary>
        /// initializes a new instance of the CRSectionContent Class.
        /// Properties settings:
        /// Header = header
        /// Type = PartContentType.ChangeRequests
        /// Content = new instance of PartDataSet.PartChangeRequestsDataTable
        /// </summary>
        /// <param name="header">BOM Section Content header</param>
        public CRSectionContent(string header)
        {
            base.Header = header;
            base.Type = PartContentType.ChangeRequests;
            base.Content = new PartDataSet.PartChangeRequestsDataTable();
        }

        /// <summary>
        /// Adds a row to Change Request Section Content initialized with given parameters
        /// </summary>
        /// <param name="date">change request date</param>
        /// <param name="requested">change request owner</param>
        /// <param name="description">change request description</param>
        /// <param name="state">change request status</param>
        public void AddCRItem(DateTime? date, string requested, string description, string state)
        {
            PartDataSet.PartChangeRequestsRow crRow = ((PartDataSet.PartChangeRequestsDataTable)base.Content).NewPartChangeRequestsRow();
            if (date != null)
                crRow.date = (DateTime)date;
            crRow.requested = requested;
            crRow.description = description;
            crRow.state = state;
            ((PartDataSet.PartChangeRequestsDataTable)base.Content).AddPartChangeRequestsRow(crRow);
        }
    }
}
